﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Work.Domain.DrugManage
{
    /// <summary>
    /// 药品出库记录
    /// </summary>
    public class DrugOutbound
    {
        /// <summary>
        /// 出库记录ID（主键）
        /// </summary>
        [Key]
        public int OutboundId { get; set; }

        /// <summary>
        /// 药品ID（外键，关联Drug表）
        /// </summary>
        public int DrugId { get; set; }

        /// <summary>
        /// 处方明细ID（外键，关联PrescriptionItem表，可选）
        /// 用于追溯出库药品来自哪个处方
        /// </summary>
        public int? PrescriptionItemId { get; set; }

        /// <summary>
        /// 预约编号（外键，关联Appintment表，可选）
        /// 用于追溯出库药品来自哪个预约
        /// </summary>
        public int? AppointmentId { get; set; }

        /// <summary>
        /// 患者ID（外键，关联Patient表）
        /// </summary>
        public int PatientId { get; set; }

        /// <summary>
        /// 卡号（冗余字段，便于快速查询）
        /// </summary>
        [MaxLength(50)]
        public string? CardNumber { get; set; }

        /// <summary>
        /// 挂号编号（冗余字段，便于快速查询）
        /// </summary>
        [MaxLength(50)]
        public string? RegistrationNum { get; set; }

        /// <summary>
        /// 患者姓名（冗余字段，便于快速查询）
        /// </summary>
        [MaxLength(100)]
        public string? PatientName { get; set; }

        /// <summary>
        /// 出库数量
        /// </summary>
        public int Quantity { get; set; }

        /// <summary>
        /// 出库单价（销售价格）
        /// </summary>
        public decimal UnitPrice { get; set; }

        /// <summary>
        /// 出库总金额（数量 × 单价）
        /// </summary>
        public decimal TotalAmount { get; set; }

        /// <summary>
        /// 出库日期
        /// </summary>
        public DateTime OutboundDate { get; set; }

        /// <summary>
        /// 操作人（执行出库操作的人员）
        /// </summary>
        [MaxLength(50)]
        public string? Operator { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string? Remarks { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; }

        // 导航属性
        /// <summary>
        /// 关联的药品信息
        /// </summary>
        public virtual Drug? Drug { get; set; }

        /// <summary>
        /// 关联的处方明细信息
        /// </summary>
        public virtual PrescriptionItem? PrescriptionItem { get; set; }

        /// <summary>
        /// 关联的预约信息
        /// </summary>
        public virtual Appintment? Appointment { get; set; }

        /// <summary>
        /// 关联的患者信息
        /// </summary>
        public virtual Patient? Patient { get; set; }
    }
}
